

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import '../../router/router_utils.dart';

class MyAppBar{

  AppBar getAppBar(
      BuildContext context,
      String title,
      {
        Widget? titleWidget,
        Widget? flexibleSpace,
        Widget? leading,
        bool? isBack = true,
        bool automaticallyImplyLeading = true,
        Color? backColor,
        Color? backgroundColor,
        TextStyle? titleTextStyle,
        Function()? onBack,
        List<Widget>? action,
        Widget? backIcon,
    }){
    
    return AppBar(
      title: titleWidget ?? Text(title, style: titleTextStyle ?? TextStyle(fontSize: 18,color:Colors.white, fontWeight: FontWeight.bold)),
      backgroundColor: backgroundColor ?? Colors.white,
      centerTitle: true,
      actions: action,
      elevation: 0,
      flexibleSpace: flexibleSpace ?? Container(
        decoration: const BoxDecoration(
          gradient: LinearGradient(
            colors: [Color(0xFF3138DF), Color(0xFF4AC9E3)],
            begin: Alignment.topLeft,
            end: Alignment.bottomRight,
          ),
        ),
      ),
      systemOverlayStyle: SystemUiOverlayStyle.dark,
      automaticallyImplyLeading: automaticallyImplyLeading,
      leading: isBack==false ? null :
      (leading ?? IconButton(icon: backIcon ?? Image.asset("assets/images/icon_back_white.png", width: 22), onPressed: onBack ?? (){
        RouterUtils.back(context);
      })),

    );

  }


}